/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dto;

import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author lab
 */
public class Question implements Serializable {

    private int id;
    private QuestionCategory category;
    private String content;
    private float mark;
    private boolean singleChoice;
    private ArrayList<Answer> answers;
    private String userAnswers;
    private byte level;

    public Question() {
        id = 0;
        category = new QuestionCategory();
        content = "";
        mark = 0;
        singleChoice = true;
        answers = new ArrayList<Answer>();
        userAnswers = "";
        level=0;
    }

    public Question(QuestionCategory category, String content, byte mark, boolean singleChoice, ArrayList<Answer> answers) {
        id = 0;
        this.category = category;
        this.content = content;
        this.mark = mark;
        this.singleChoice = singleChoice;
        this.answers = answers;
        userAnswers = "";
        level=0;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the category
     */
    public QuestionCategory getCategory() {
        return category;
    }

    /**
     * @param category the category to set
     */
    public void setCategory(QuestionCategory category) {
        this.category = category;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * @return the mark
     */
    public float getMark() {
        return mark;
    }

    /**
     * @param mark the mark to set
     */
    public void setMark(float mark) {
        this.mark = mark;
    }

    /**
     * @return the singleChoice
     */
    public boolean isSingleChoice() {
        return singleChoice;
    }

    /**
     * @param singleChoice the singleChoice to set
     */
    public void setSingleChoice(boolean singleChoice) {
        this.singleChoice = singleChoice;
    }

    /**
     * @return the answers
     */
    public ArrayList<Answer> getAnswers() {
        return answers;
    }

    /**
     * @param answers the answers to set
     */
    public void setAnswers(ArrayList<Answer> answers) {
        this.answers = answers;
    }

    /**
     * @return the userAnswers
     */
    public String getUserAnswers() {
        return userAnswers;
    }

    /**
     * @param userAnswers the userAnswers to set
     */
    public void setUserAnswers(String userAnswers) {
        this.userAnswers = userAnswers;
    }

    /**
     * @return the level
     */
    public byte getLevel() {
        return level;
    }

    /**
     * @param level the level to set
     */
    public void setLevel(byte level) {
        this.level = level;
    }
    
    public boolean checkAnswer(){        
        for(Answer ans:this.answers){
            if(ans.getIsUserChoice()&& !ans.getIsTrue() || !ans.getIsUserChoice()&& ans.getIsTrue()){
               return false;
            }
        }
        return true;
    }
}
